package tmooc._0505;

import java.util.Scanner;

public class demo05 {

    public static void main(String[] args) {
        /*
         double[] scores = inputData(6);
        double avg = calAvg(scores);
        System.out.println("平均分为:" + avg);
         */

        /*
         double[] scores = inputData(6);
        double avg = calAvg(scores);
        System.out.println("平均分为:" + avg);
         */
        double[] scores = inputData(6);
        double avg = calAvg(scores);
        System.out.println("平均分为:" + avg);
    }


/*
    public static double[] inputData(int count) {
        Scanner scan = new Scanner(System.in);
        double[] scores = new double[count];
        for (int i = 0; i < scores.length; i++) {
            System.out.println("请输入第" + (i + 1) + "位评委的分数");
            scores[i] = scan.nextDouble();
        }
        return scores;
    }


    public static double calAvg(double[] scores) {
        double total = calTptal(scores);
        double avg = total / (scores.length-2);
        return avg;
    }


    public static double calTptal(double[] scorse){
        double total = 0.0;
        double max = scorse[0];
        double min = scorse[0];
        for (int i = 0 ; i <scorse.length ; i++){
            if (scorse[i]> max){
                max = scorse[i];
            }
            if (scorse[i]<min){
                min = scorse[i];
            }
            total += scorse[i];

        }

        return total - max - min;

    }
    */

/*
    public static double[] inputData(int count) {
        Scanner scan = new Scanner(System.in);
        double[] scores = new double[count];
        for (int i = 0; i < scores.length; i++) {
            System.out.println("请输入第" + (i + 1) + "位评委的分数");
            scores[i] = scan.nextDouble();
        }
        return scores;
    }


    public static double calAvg(double[] scores) {
        double total = calTptal(scores);
        double avg = total / (scores.length-2);
        return avg;
    }


    public static double calTptal(double[] scorse){
        double total = 0.0;
        double max = scorse[0];
        double min = scorse[0];
        for (int i = 0 ; i <scorse.length ; i++){
            if (scorse[i]> max){
                max = scorse[i];
            }
            if (scorse[i]<min){
                min = scorse[i];
            }
            total += scorse[i];

        }

        return total - max - min;

    }

 */

    public static double[] inputData(int count) {
        Scanner scan = new Scanner(System.in);
        double[] scores = new double[count];
        for (int i = 0; i < scores.length; i++) {
            System.out.println("请输入第" + (i + 1) + "位评委的分数");
            scores[i] = scan.nextDouble();
        }
        return scores;
    }


    public static double calAvg(double[] scores) {
        double total = calTptal(scores);
        double avg = total / (scores.length-2);
        return avg;
    }


    public static double calTptal(double[] scorse){
        double total = 0.0;
        double max = scorse[0];
        double min = scorse[0];
        for (int i = 0 ; i <scorse.length ; i++){
            if (scorse[i]> max){
                max = scorse[i];
            }
            if (scorse[i]<min){
                min = scorse[i];
            }
            total += scorse[i];

        }

        return total - max - min;

    }
}
